package com.xyoto.community.task;

import com.xyoto.community.constant.moduleConstant;
import com.xyoto.community.entity.main.HotDynamic;
import com.xyoto.community.utils.RedisCommonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class HotDynamicRedisImpl {

    @Autowired
    private RedisCommonUtils redisCommonUtils;

    /**
     *
     * @param hotDynamics
     */
    public void saveHotDynamic(List<HotDynamic> hotDynamics) {

        for (HotDynamic hotDynamic : hotDynamics) {
            redisCommonUtils.zSet(moduleConstant.HOT_DYNAMIC,hotDynamic.getDynamicId(),hotDynamic.getCurrentHot().doubleValue());
        }

        log.info("添加后的热门动态为" + redisCommonUtils.rangeByZSetAll(moduleConstant.HOT_DYNAMIC));

    }
}
